﻿using ZilLion.Core.Unities.UnitiesMethods.WebApi.Http;
using ZilLion.Task.Domain.Taskmanager.Entity;
using ZilLion.Task.Domain.Taskmanager.Response;
using ZilLion.Task.Domain.WebEntity;

namespace ZilLion.Task.Domain.Taskmanager.Repository
{
    public class TaskModuleConfigRespository : WebApiRepositoryBase<HttpNoCompressionClient>
       
    {
        public TaskModuleConfigResponse GetTaskModuleConfig()
        {
            var url =
                @"Api/TaskConfig/GetAllTaskModuleConfig";
            return HttpGet<TaskModuleConfigResponse>(url);
        }

        public TaskModuleConfigResponse GetTaskModuleConfigById(string moduleid)
        {
            var url =
                $"Api/TaskConfig/GetTaskConfig/{moduleid}";
            return HttpGet<TaskModuleConfigResponse>(url);
        }

        public UploadTaskPackageResponse UpLoadPackageFile(string filepath)
        {
            var url =
                @"Api/UploadTaskPackage/Upload";
            return UpLoadFile<UploadTaskPackageResponse>(url, filepath);
        }

        public bool SaveTaskModuleConfig(TaskModuleConfigEntity entity)
        {
            const string url = @"Api/TaskConfig/SaveModuleConfig";

            var response = HttpPost<TaskModuleConfigEntity, ResponseResultInfo>(entity, url);
            return (response != null) && response.IsSuccess;
        }
    }
}